package com.goldgov.code.meta;

import com.goldgov.code.utils.StringUtils;

public class RelationInfo {

	private final ModuleInfo relationModule;
	private final RelationType type;
	private String relationField;
	private String relationName;
	
	public RelationInfo(ModuleInfo relationModule,RelationType type){
		this.relationModule = relationModule;
		this.type = type;
	}

	public ModuleInfo getRelationModule() {
		return relationModule;
	}

	public RelationType getType() {
		return type;
	}
	
	public String getRelationField() {
		return relationField;
	}

	public void setRelationField(String relationField) {
		this.relationField = relationField;
	}

	public String getRelationName() {
		if(relationName == null) {
			relationName = StringUtils.lowerFirstChar(relationModule.getName());
		}
		return relationName;
	}

	public void setRelationName(String relationName) {
		this.relationName = relationName;
	}



	public enum RelationType{
		ONE_TO_MANY,MANY_TO_ONE;
	}
	
}
